package cn.tedu.test.config.condition.config;

import cn.tedu.test.annotation.ConditionalOnWindows;
import cn.tedu.test.bean.Bean04;
import cn.tedu.test.config.condition.OnWindowsCondition;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
//1. property格式文件 肯定key=value 只指定key值 可以指定多个
//prefix+value 或者 使用value单独指定key luban.user.name luban.user.password
//@ConditionalOnProperty(prefix="luban.user",value={"name","aaa"})
//2. 指定属性key的具体值
//@ConditionalOnProperty(value={"luban.user.name"},havingValue = "wangcuihua")
//3. 配置matchIfMissing
@ConditionalOnProperty(
        value="luban.user.password",
        havingValue = "123",
        matchIfMissing = true)
//@ConditionalOnWindows
//@ConditionalOnMissingClass(value = {"cn.tedu.AAA"})
public class MyConditionConfig01 {
    public MyConditionConfig01() {
        System.out.println("条件配置01满足条件被容器加载");
    }
    @Bean
    //@ConditionalOnMissingBean(type = {"cn.tedu.AAA"})
    //@Conditional(OnWindowsCondition.class)
    public Bean04 bean04(){
        return new Bean04();
    }
}
